<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>

  <script>
    let data = {
      message: 'Hello',
    }

    const render = function() {
      const html = `
        <div>
          ${data.message}
        </div>
      `
      document.querySelector('#app').innerHTML = html
    }

    render()
  </script>

  <script>
    // 利用 Proxy 来实现数据代理：
    data = new Proxy(data, {
      get(obj, attr) {
        console.log('getter...')
        return obj[attr]
      },
      set(obj, attr, value) {
        console.log('setter...')
        obj[attr] = value
        render()
      }
    })
  </script>
</body>
</html>